<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <button id="ks">开始</button>
    <button id="js">结束</button>
    <h1 id="txt">开始抽奖</h1>


    <script>
    var tag1=document.getElementById('txt');
    var tag=document.getElementById('ks');
    var tag2=document.getElementById('js');
    var timer;
    var list=['22','58','34','66','68']
        //Math.random（）产生随机数0-1之间的随机数 包含0 不包含1
        //parseint（a）转化为整数
    console.log(list[0]);
        // console.log(parseInt(Math.random()*10))
    console.log(list.length);
    
    
    
    tag.onclick=function()
    {
        clearInterval(timer);
        timer=setInterval(function(){
        var n=parseInt(Math.random()*list.length);
        tag1.innerHTML=list[n]
        },100)
    }

    
    
    
    tag2.onclick=function(){
        clearInterval(timer);
    }


   
    </script>
</body>
</html>